define(['registry', 'models/record', 'views/form'],

function(app_registry, Record, Form) {
  var ItemView = Backbone.View.extend({
    el: '#item-detail-view',

    template: _.template($('#item-detail-template').html()),

    events: {
      'update_detail': 'updateDetail',
    },

    initialize: function() {
      this.model = new Record();
      this.listenTo(this.model, 'change', this.render);
    },

    render: function() {
      this.$el.html(this.template(this.model.toJSON()));
      return this;
    },

    updateDetail: function(e, data) {
      var m = this.collection.get(data.id) || new Record();
      this.model.set(m.toJSON())
    }
  });

  return ItemView;
});
